home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagd_f.zip / FILES.SWG / 0013_TRUENAME.PAS.pas < prev    next >
Pascal/Delphi Source File  |  1993-05-28  |  839b  |  42 lines

  1. {
  2. NORBERT IGL
  3.  
  4. > Anyone has got an idea on how to know if a drive is a real one or the
  5. > result of a SUBST command Any help... welcome :-)
  6.  
  7. Well, DOS ( esp. COMMAND.COM ) has a undocumented Command
  8. called TRUENAME, which takes wildcards also.
  9. }
  10.  
  11. Program TrueName;
  12.  
  13. uses
  14.   DOS;
  15.  
  16. function RealName(FakeName : String) : String;
  17. Var
  18.   Temp : String;
  19.   Regs : Registers;
  20. begin
  21.   FakeName := FakeName + #0; { ASCIIZ }
  22.   With Regs do
  23.   begin
  24.     AH := $60;
  25.     DS := Seg(FakeName);
  26.     SI := Ofs(FakeName[1]);
  27.     ES := Seg(Temp);
  28.     DI := OfS(Temp[1]);
  29.     INTR($21, Regs);
  30.     DOSERROR := AX * ((Flags And FCarry) shr 7);
  31.     Temp[0] := #255;
  32.     Temp[0] := CHAR(POS(#0, Temp) - 1);
  33.   end;
  34.   If DosError <> 0 then
  35.     Temp := '';
  36.   RealName := Temp;
  37. end;
  38.  
  39. begin
  40.   writeln(RealName(Paramstr(0)));
  41. end.
  42.